var initActionsInfoBean;
var getActionsInfoBeanFromOpenPage = function(){
	var actionsinfoBean = {};
	
	actionsinfoBean.id = jQuery('#idEditor').val();
	
	actionsinfoBean.name = jQuery('#nameEditor').val();
	if(!actionsinfoBean.name){
		$.ligerDialog.error("请输入名称!");
		return null;
	}	
	actionsinfoBean.type = jQuery('#typeEditor').val();
	if(!actionsinfoBean.type){
		$.ligerDialog.error("请输入类型!");
		return null;
	}	
	actionsinfoBean.path = jQuery('#pathEditor').val();
	if(!actionsinfoBean.path){
		$.ligerDialog.error("请输入路径!");
		return null;
	}	
	actionsinfoBean.pid = jQuery('#pidEditor').val();
	if(!actionsinfoBean.pid){
		if(actionsinfoBean.type==1){
			actionsinfoBean.pid = 0;
		}
	}	
	
	if(actionsinfoBean.pid !=0 && (actionsinfoBean.pid == actionsinfoBean.id)){
		$.ligerDialog.error("上级不能是自己!");
		return null;
	}
	return actionsinfoBean;
};

var initActionsInfoPage = function(){
	
	jQuery('#ligerType').ligerComboBox({
		data:actionTypesRenderData,
		valueField:'value',
		textField:'text',
		disabled:true,
		valueFieldID:'typeEditor'
	});
};

var bindActionsInfoUpdateButtom = function(){
	jQuery('#updateEdit').unbind('click').click(function(){
		var actionsinfoBean = getActionsInfoBeanFromOpenPage();
		if(null != actionsinfoBean){
			doSaveActionsInfos([actionsinfoBean]);
		}
	});
};
var bindActionsInfoResetButtom = function(){
	jQuery('#resetEdit').unbind('click').click(function(){
		if(!initActionsInfoBean){
			jQuery("#nameEditor").val('');
			jQuery("#typeEditor").val('');
			jQuery("#pathEditor").val('');
			jQuery("#pidEditor").val('');
		}else{
			if(!initActionsInfoBean.name){
				jQuery("#nameEditor").val('');
			}else{
				jQuery("#nameEditor").val(initActionsInfoBean.name);
			}
			if(!initActionsInfoBean.type){
				jQuery("#typeEditor").val('');
			}else{
				jQuery("#typeEditor").val(initActionsInfoBean.type);
			}
			if(!initActionsInfoBean.path){
				jQuery("#pathEditor").val('');
			}else{
				jQuery("#pathEditor").val(initActionsInfoBean.path);
			}
			if(!initActionsInfoBean.pid){
				jQuery("#pidEditor").val('');
			}else{
				jQuery("#pidEditor").val(initActionsInfoBean.pid);
			}
		}
	});
};

jQuery(function(){
	initActionsInfoPage();
	bindActionsInfoUpdateButtom();
	bindActionsInfoResetButtom();
});